/**
 * Created by blatand on 2017/2/9.
 */
public class Msg8583Util {

    static final int  TYPE_ONE          = 1;
    static final int  TYPE_LLVAR        = 92;
    static final int  TYPE_BCDLLVAR     = 93;
    static final int  TYPE_LLLVAR       = 94;
    static final int  TYPE_BCDLLLVAR    = 95;

    private static byte[] msgLen;
    private static byte[] msgValue;
    private static byte[] tpdu;
    private static byte[] appDat;
    private static byte[] bitmap;
    private static byte[] msgType;
    private static int[] domainNum;
    private static int[] len;
    private static byte[][] value;

    public Msg8583Util() {

        this.msgLen = new byte[2];
        this.msgValue = new byte[1024];
        this.tpdu = new byte[5];
        this.appDat = new byte[6];
        this.bitmap = new byte[8];
        this.msgType = new byte[2];
        this.domainNum = new int[129];
        this.len = new int[129];
        this.value = new byte[129][256];
    }

    public void setTpdu(byte[] tpdu ){
        this.tpdu = tpdu;
    }
    public byte[] getTpdu(){
        return this.tpdu;
    }




    public void setBitMap(byte bm[]){

        this.bitmap =  bm;
    }
    public byte[] getBitMap(){
        return this.bitmap;
    }


    public  void AppendMsgValue(int curPos,byte[] value,int len){
        System.arraycopy(value,0,msgValue,curPos,len);
//        this.msgLen[0] += len;
    }
    public static byte[] getPackMsgValue(){

        return msgValue;
    }


    public  int getBit(int n){
        if(this.domainNum[n]==1){
            return n;
        }else{
            return 0;
        }
    }
    public  int getSpecifiedMsgLen(int n){

        return this.len[n];
    }
    public  byte[] getSpecifiedMsgValue(int n){

        return this.value[n];
    }
    public  void setBit(int n){
        this.domainNum[n] =  1;
    }
    public  void setLen(int n,int lenght){
        this.len[n] = lenght;
    }
    public void setBitValue(int n, int len, byte[] data){

        this.setBit(n);
        this.setLen(n,len);
        this.value[n] = data;
    }

    public static Msg8583Util Unpackbag(byte[]  msg, String filePath){

        return MsgUnPack.ParseMessage(msg,filePath);
    }

//    public static byte[] Packbag(int tradeType){
//
////        return PackMsg.Packbag(tradeType);
//    }
}
